// luadll.cpp: implementation of the luadll class.
//
//////////////////////////////////////////////////////////////////////

#include "luadll.h"
#include <math.h>
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
};


#pragma comment(lib,"lua5.1.lib") 
#pragma comment(lib,"lua51.lib") 

#define MYDLL_EXPORTS
#ifdef  MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

luadll::luadll()
{

}

luadll::~luadll()
{

}

extern "C" MYDLL_API int LuaDllFunc(lua_State* L)
{
	lua_pushstring(L,"Load LuaDllFunc :)");
	return 1;
}

static int l_sin(lua_State *L){
	double d = luaL_checknumber(L,1); //the argument
	lua_pushnumber(L,sin(d)); //the result
	return 1; //the result number
}



static const struct luaL_Reg mylibs[] = {
	{"mysin",l_sin},
	{NULL,NULL}
};

int lua_openmylib(lua_State* L)
{
	luaL_register(L,"mylibs",mylibs);
	return 1;
}

int __cdecl __declspec(dllexport) luaopen_myluadll(lua_State* L)
{
//	luaL_openlibs(L,"mylibs",mylibs,0);
	return 0;
}